package com.wgtp.ssapp.view.activity;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

import com.wgtp.ssapp.R;
import com.wgtp.ssapp.model.SubForum;
import com.wgtp.ssapp.model.tasks.LoginTask;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class LoginActivity extends Activity {
    
	private TextView usernameField, passwordField;
	private Button loginButton;
	private String code, TAG = "LoginActivity";
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login_page);
        
        startActivity(new Intent(this, ForumListActivity.class));
        
//        loginButton = (Button) this.findViewById(R.id.loginButtonLoginPage);
//        usernameField = (TextView) this.findViewById(R.id.usernameFieldLoginPage);
//        passwordField = (TextView) this.findViewById(R.id.passwordFieldLoginPage);
//        
//        loginButton.setOnClickListener(new OnClickListener(){
//        	@Override
//			public void onClick(View arg0) {
//        		Log.i(TAG, "login method starting.");
//        		
//				login(usernameField.getText().toString(), passwordField.getText().toString());
//				
//				Log.i(TAG, "login method complete.");
//			}
//        });
    }
    
    public void successfulLogin() {
    	Intent i = new Intent(this, ForumListActivity.class);
    	startActivity(i);
    	this.finish();
    }
    
    
    /**
     * @param username
     * @param password
     */
    public void login(final String username, final String password) {
    	Log.i(TAG, "starting login task");
    	
    	new LoginTask(username, password, this).execute(username, password);    	
    }   
}